<%Option Explicit
Dim conn,db,rs,cmd
Set conn = server.CreateObject("ADODB.CONNECTION")
db = "Provider=Microsoft.ACE.OLEDB.12.0;data source=e:\baoguan\d.accdb"
conn.Open db
set rs=server.createobject("adodb.recordset")
set cmd=server.createobject("adodb.command")
cmd.ActiveConnection = conn
Public Sub t1()
    'conn.Execute "delete from table1 where id=1234"
    
     
    Dim ssql 
    ssql = "select * from table1 where id=1234"
    rs.Open ssql, conn, 3, 3
    If rs.EOF Then
        rs.AddNew
        rs.Fields("id").Value = 1234
    End If
    rs.Fields("cname").Value = "KKK"
    rs.Update
    rs.Close
End Sub

Public Sub t2()
    'conn.Execute "delete from table1 where id=1234"
    
     
    Dim ssql 
    ssql = "select * from table1 where id=1234"
    rs.Open ssql, conn
    If rs.EOF Then
        ssql = "insert into table1 values(1234,'1234')"
    Else
        ssql = "update table1 set cname='1234' where id=1234"
    End If
    rs.Close
    conn.Execute ssql
End Sub

Public Sub t3()
    'conn.Execute "delete from table1 where id=1234"
    
    Dim ssql 
    Dim nAffectedRow 
    
    ssql = "update table1 set cname='1234' where id=1234"
    conn.Execute ssql, nAffectedRow
    
    If nAffectedRow = 0 Then
        ssql = "insert into table1 values(1234,'1234')"
        conn.Execute ssql, nAffectedRow
    End If
    
End Sub

Public Sub t4()
    'conn.Execute "delete from table1 where id=1234"
    
    Dim ssql 
    
    ssql = "delete from table1 where id=1234"
		cmd.CommandText = ssql
		cmd.Execute
    'conn.Execute ssql
    
    ssql = "insert into table1 values(1234,'1234')"
		cmd.CommandText = ssql
		cmd.Execute
    'conn.Execute ssql
    
End Sub




    Dim i 
    Dim nCnt 
    nCnt = 5000
    dim ts,te
		ts=timer
    For i = 1 To nCnt
        Call t1
    Next 
		te=timer
    response.write "t1 end:"& te-ts&"<br />"
    
		ts=timer
    For i = 1 To nCnt
        Call t2
    Next 
		te=timer
    response.write "t2 end:"& te-ts&"<br />"
    
		ts=timer
    For i = 1 To nCnt
        Call t3
    Next 
		te=timer
    response.write "t3 end:"& te-ts&"<br />"
    
		ts=timer
    For i = 1 To nCnt
        Call t4
    Next 
		te=timer
    response.write "t4 end:"& te-ts&"<br />"
    

set cmd=nothing
conn.close
set conn=nothing
%>
